#!/bin/bash

xlen="$(march-to-cpu-opt --elf-file-path $1 --print-xlen)"
isa="$(march-to-cpu-opt --elf-file-path $1 --print-spike-isa)"
varch="$(march-to-cpu-opt --elf-file-path $1 --print-spike-varch)"

isa_option="--isa=${isa}"
varch_option=""
memory_option="--misaligned"

[[ ! -z ${varch} ]] && varch_option="--varch=${varch}"

spike ${memory_option} ${isa_option} ${varch_option} ${PK_PATH}/pk${xlen} "$@"
